<template>
  <Dialog :title="dialogTitle" v-model="dialogVisible">
    <el-radio-group v-model="checkedRadio" class="pl-40px gw-radio">
      <el-radio :label="0">规则评分</el-radio>
      <el-radio :label="1" disabled>人工评分</el-radio>
      <el-radio :label="2" disabled>模型评分</el-radio>
  </el-radio-group>
    <template #footer>
      <el-button @click="submitForm" type="primary">确定</el-button>
    </template>
  </Dialog>
</template>
<script setup lang="ts">
import { EvaluationTaskApi } from '@/api/multiModel/evaluationtask'
/** 评测任务 表单 */
defineOptions({ name: 'JudgingRules' })

const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗

const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = '评分类型选择' // 弹窗的标题
let checkedRadio = ref(0)
const evaluationTaskId = ref(0)

/** 打开弹窗 */
const open = async (id: number) => {
  dialogVisible.value = true
  resetForm()
  evaluationTaskId.value = id
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗

/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件，用于操作成功后的回调
const submitForm = async () => {
  // 提交请求
  try {
    const data = {
      id: evaluationTaskId.value,
      type: checkedRadio.value
    }
    await EvaluationTaskApi.getModelEvaluation(data)
    message.success(t('common.updateSuccess'))
    dialogVisible.value = false
    // 发送操作成功的事件
    emit('success')
  } catch(e:any) {

  }
}

/** 重置表单 */
const resetForm = () => {
  checkedRadio.value = 0
}
</script>
<style lang="scss" scoped>
</style>